home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir37
/
splt-bat.zip
/
TEST.BAT
< prev
Wrap
DOS Batch File
|
1993-03-23
|
5KB
|
190 lines
@ECHO OFF
REM If no file specified go to end
IF "%1"=="" GOTO End
REM Converts input to upper case. Not necessary but I used it to get the output
REM at the end in uppercase. This particular routine, except the line reading
REM SET Pathname= should be removed. %UpCase% should then be be changed to
REM %1. It should also be changed everywhere else in the file. These places
REM will be indicated by asterisks.
SET OldPath=%Path%
PATH=%1
SET UpCase=%Path%
SET Path=%OldPath%
SET PathName=%UpCase%
SET OldPath=
REM this routine determines if a path was attached to the file specified.
REM If no path was indicated the batch then branches to SetExt.
:PathSeek
SET Prev=%PathName%
FOR %%a IN (/%pathName%) DO SET PathName=%%a
IF "\%PathName%"=="%Prev%" GOTO PathFound
SET Count=%Count%x
IF NOT "%PathName%"=="%Prev%" GOTO PathSeek
REM *****************
SET FileName=%UpCase%
SET PathName=
GOTO SetExt
:PathFound
REM **************** Little square box entered with Alt-254 on numeric keypad
SET PathName=%UpCase%■
SET Count=
SET BackCount=
REM this routine determines the path's length.
:PathLength
SET Prev=%PathName%
FOR %%a IN (/%PathName%) DO SET PathName=%%a
FOR %%a IN (/%Prev%) DO IF "%%a"=="\" GOTO BackSlash
FOR %%a IN (/%Prev%) DO IF "%%a"=="■" GOTO FileSetup
SET Count=%Count%x
REM ECHO Value of PathName is %PathName%
REM ECHO Value of Count %Count%
GOTO PathLength
:BackSlash
REM ECHO VALUE OF PATHNAME IS %PathName%
SET BackCount=%BackCount%x
GOTO PathLength
:FileSetup
REM *****************
SET FileName=%UpCase%
SET BkCount=
REM This routine gets the filename with its extension.
:FileGet
SET Prev=%FileName%
FOR %%a IN (/%FileName%) DO SET FileName=%%a
FOR %%a IN (/%Prev%) DO IF "%%a"=="\" GOTO Back
REM ECHO Value of FileName is %FileName%
GOTO FileGet
:Back
REM ECHO VALUE OF FileName IS %FileName%
SET BkCount=%BkCount%x
IF NOT "%BkCount%"=="%BackCount%" GOTO FileGet
SET TempFile=%FileName%■
SET Count=
REM this routine gets the file and its extension's length.
:FileLength
SET Prev=%TempFile%
FOR %%a IN (/%TempFile%) DO SET TempFile=%%a
FOR %%a IN (/%Prev%) DO IF "%%a"=="■" GOTO PathSetup
SET Count=%Count%x
REM ECHO Value of TempFile is %TempFile%
REM ECHO Value of Count is %Count%
GOTO FileLength
:PathSetup
SET Count=%Count%x
REM *****************
SET PathName=%UpCase%
SET BkCount=
SET File=
SET TempFile=
REM the following routines will get the files pathname.
:PathGet1
SET Prev=%PathName%
FOR %%a IN (/%PathName%) DO SET PathName=%%a
FOR %%a IN (/%Prev%) DO IF "%%a%PathName%"=="%Prev%" SET PathName=%PathName%%%a
FOR %%a IN (/%Prev%) DO IF "%%a"=="\" GOTO BackAgain
REM ECHO Value of PathName is %PathName%
GOTO PathGet1
:BackAgain
REM ECHO VALUE OF PATHNAME IS %PathName%
SET BkCount=%BkCount%x
IF NOT "%BkCount%"=="%BackCount%" GOTO PathGet1
SET Counter=
:PathGet2
FOR %%a IN (/%PathName%) DO SET PathName=%%a
SET Counter=%Counter%x
REM ECHO VALUE OF PATHNAME IS %PathName%
IF NOT "%Counter%"=="%Count%" GOTO PathGet2
SET Counter=
SET Count=
SET BkCount=
SET BackCount=
:SetExt
SET Ext=%FileName%
REM this routine checks to see if the specified file had an extension.
REM This comes from Prof. Timo Salmi's collection of batch files TSBAT*.ZIP
REM a good primer for batch programming.
:ExtCheck
SET Prev=%Ext%
FOR %%a IN (/%Ext%) DO SET Ext=%%a
IF ".%Ext%"=="%Prev%" GOTO ExtFound
REM ECHO Value of Ext is %Ext%
SET Count=%Count%x
IF NOT "%Ext%"=="%Prev%" GOTO ExtCheck
SET Name=%FileName%
SET Ext=
GOTO NoExt
:ExtFound
SET Prev=
SET Len=
SET NewExt=%Ext%■
REM this routine determines the length of the extension.
:FindLen
FOR %%a IN (/%NewExt%) DO SET NewExt=%%a
SET Len=%Len%x
IF NOT "%NewExt%"=="■" GOTO FindLen
SET NewExt=
SET Name=%FileName%
SET NewCount=
REM the following routines chop off the extension to get the files's name.
:ChopExt
SET Prev=%Name%
FOR %%a IN (/%Name%) DO SET Name=%%a
FOR %%a IN (/%Prev%) DO IF "%%a%Name%"=="%Prev%" SET Name=%Name%%%a
REM ECHO Value of Name is %Name%
SET NewCount=%NewCount%x
IF NOT "%Count%"=="%NewCount%" GOTO ChopExt
SET NewCount=
SET NewLen=
:GetName
SET Prev=%Name%
FOR %%a IN (/%Name%) DO SET Name=%%a
REM ECHO Value of Name is %Name%
SET NewLen=%NewLen%x
IF NOT "%NewLen%"=="%Len%x" GOTO GetName
SET NewLen=
SET Len=
:NoExt
SET FileName=
SET Count=
SET Prev=
IF NOT "%PathName%"=="" SET PathState=full Path Name is "%PathName%",
IF NOT "%Name%"=="" SET NameState=Name is "%Name%"
IF NOT "%Ext%"=="" SET ExtState=, and Extension is "%Ext%"
cls
ECHO B
"%UpCase%"'s %PathState% %NameState%%ExtState%
SET PathState=
SET NameState=
SET ExtState=
:End